home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 …ember: Reference Library / Apple Developer Reference Library (December 1999) (Disk 1).iso / pc / what's new / sample code / printing / scriptable print simpletext / extendprintrecord.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-04  |  2.5 KB  |  82 lines

  1. /*
  2. **    File:        ExtendPrintRecord.c
  3. **
  4. **    Functions defined in Technote 1161
  5. **
  6. ** Copyright 1996-1999 Apple Computer. All rights reserved.
  7. **
  8. **    You may incorporate this sample code into your applications without
  9. **    restriction, though the sample code has been provided "AS IS" and the
  10. **    responsibility for its operation is 100% yours.  However, what you are
  11. **    not permitted to do is to redistribute the source as "DSC Sample Code"
  12. **    after having made changes. If you're going to re-distribute the source,
  13. **    we require that you make it clear in the source that the code was
  14. **    descended from Apple Sample Code, but that you've made changes.
  15. */
  16.  
  17. #include <Printing.h>
  18. #include "ExtendPrintRecord.h"
  19.  
  20. Boolean extendPrValidate(THPrint hPrint)
  21. /* 
  22. The current driver is asked to extend the print record.
  23. If this fails, the print record handle is sized to the standard
  24. size print record (120 bytes).
  25. The current printer driver's PrValidate() routine is called to
  26. validate the print record whether it has been successfully
  27. extended or not.
  28. */
  29. {
  30.     /* 
  31.     In case 'hPrint' is extended and the current printer driver doesn't
  32.     support the extensible print record, we let extendPrintRecord()
  33.     truncate the print record. The print record won't be truncated
  34.     if the print record is already the standard size or if the current 
  35.     driver supports the extensible print record.
  36.     */
  37.     extendPrintRecord(hPrint);
  38.  
  39.     /* Call the real PrValidate with a correctly sized print record. */
  40.     return PrValidate(hPrint);
  41. }
  42.  
  43.  
  44. void extendPrDefault(THPrint hPrint)
  45. {
  46.     /* 
  47.     The default print record is the standard size for all drivers.
  48.     So default the 120-byte record.
  49.     */
  50.     SetHandleSize((Handle)hPrint, sizeof(TPrint));
  51.     PrintDefault(hPrint);
  52.  
  53.     /* 
  54.     Tell the printer driver it is okay to extend this print record.
  55.     */
  56.     extendPrintRecord(hPrint);
  57. }
  58.  
  59.  
  60. void extendPrintRecord(THPrint hPrint)
  61. {
  62.     TExtendPrintRecord extend;
  63.     /* 
  64.     Call the new PrGeneral opcode to see if the current printer driver
  65.     supports extended print records. If the driver does support extended
  66.     print records, it returns noErr. It marks the print record as
  67.     extensible and may also extend it at this time.
  68.     If the driver does not support extended print records,
  69.     it returns 'OpNotImpl'.
  70.     */
  71.     extend.iOpCode = kExtendPrintRecordOp;
  72.     extend.lReserved = 0;
  73.     extend.hPrint = hPrint;
  74.     PrGeneral((Ptr)&extend);
  75.  
  76.     /* 
  77.     If the driver fails to make the print record extensible,
  78.     we make sure the print record is the standard 120 bytes.
  79.     */
  80.     if(extend.iError) SetHandleSize((Handle)hPrint, sizeof(TPrint));
  81. }
  82.